import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes: Array<RouteRecordRaw> = [{
  path: '/login',
  name: 'login',
  meta: {
    title: "登录",
  },
  component: () => import('../views/login.vue'),
}, {
  path: '/',
  name: 'index',
  redirect: "/home",
  component: () => import('../views/main/index.vue'),
  children: [],
  // children: [{
  //   path: '/home',
  //   name: 'home',
  //   meta: {
  //     title: "首页",
  //   },
  //   component: () => import('../views/home.vue'),
  // }, {
  //   path: '/system/user/index',
  //   name: 'systemUser',
  //   meta: {
  //     title: "用户管理",
  //   },
  //   component: () => import('../views/system/user/index.vue'),
  // }, {
  //   path: '/system/post/index',
  //   name: 'systemPost',
  //   meta: {
  //     title: "岗位管理",
  //   },
  //   component: () => import('../views/system/post/index.vue'),
  // }, {
  //   path: '/system/dept/index',
  //   name: 'systemDept',
  //   meta: {
  //     title: "部门管理",
  //   },
  //   component: () => import('../views/system/dept/index.vue'),
  // }, {
  //   path: '/system/menu/index',
  //   name: 'systemMenu',
  //   meta: {
  //     title: "菜单管理",
  //   },
  //   component: () => import('../views/system/menu/index.vue'),
  // }, {
  //   path: '/system/role/index',
  //   name: 'systemRole',
  //   meta: {
  //     title: "角色管理",
  //   },
  //   component: () => import('../views/system/role/index.vue'),
  // }],
}
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  NProgress.configure({ showSpinner: false })
  NProgress.start()

  next()
})

// 路由加载后
router.afterEach(() => {
  NProgress.done()
})

export default router
